import {request} from "../../request/http"
Page({
  data:{
   inpValue:'',
   goods:[],
   hidden:true, 
  },

  onLoad(){
    
  },
  //输入内容触发-
  handleInput(e){
   const {inpValue}= this.data
     if(inpValue.length>0){
         this.getSearchList()
     }
     
  },
async getSearchList(){
     //走接口
     const {inpValue}= this.data
     let res=await request({url:`goods/search?query=${inpValue}`})
     console.log('搜索',res);


     if(res.meta.status===200){
      let goods=res.message.goods
     this.setData({
      goods
 })
     } 

 },
 //取消
 handleCancel(){
     this.setData({
       inpValue:'',
       goods:[]
     })
 }
})